Short:    Memory defragmentizer/AllocP superset
Author:   thor@math.tu-berlin.de (Thomas Richter)
Uploader: thor@math.tu-berlin.de (Thomas Richter)
Version:  1.19.1
Type:     util/sys

______________________________________________________________________________

Changed the name of the DefragMeter to FragMeter because that makes more
sense. Added a chunk count to this program. PoolMem itself unchanged.
______________________________________________________________________________

About PoolMem:
	
	If you run a lot of programs without resetting the system, you'll
usually find that the main memory of the computer is getting "messed up",
split in lots of tiny memory "snippets" that are more or less useless due to
their tinyness. It may happen that you can't start an application even though
enough memory is available - because this memory is too fragmentated to
be of any use.

That's the point where PoolMem tries to help you: It manages the main memory
in a way such that it can't get fragmentated too easely. It replaces also
the function of AllocP, which is therefore obsolete.

______________________________________________________________________________

Installation and Usage:

	Copy the PoolMem program in this archive to the C: directory of your
system partition. Add the following line to your startup-sequence:

PoolMem >NIL:


You might also want to install "PatchRAM" which is included in this archive,
too. It modifies the system RAM disk in a way that avoids memory 
fragmentation, too. Another bonus is that the RAM disk will show its true
size from now on, i.e. it won't be no longer 100% full.


To remove PoolMem later on, open a shell window and enter

PoolMem remove

______________________________________________________________________________

Compatibility:

	There are a couple of relatively deep patches of the memory system
that shouldn't be run together with PoolMem:

- SetPatch:	The 68040 library which is loaded by this program seems
		to allocate the MMU tables in a strange way incompatible
		to the scratch list of PoolMem. Easy solution: run
		PoolMem after SetPatch.
- MemSniff:	(The THOR MungWall replacement)	Patches deep into the memory
		allocation routines, too deep for PoolMem.

I guess that's all for now...

______________________________________________________________________________

Theory of operation:

	PoolMem splits all available memory in two blocks: One block is used 
for the small memory snippets (always taken from there), the other block is used
for huge allocations. This partition of the main memory is dynamic, i.e. each
sub-pool can grow and shrink, depending on the memory requirements.

The "public/ANY" memory gets a special treatment. PoolMem manages a "scratch"
list for tiny memory blocks taken from there. Instead of taking these tiny
memory blocks always from the main memory, they are taken from this (global,
though) memory pool and put back into this pool if they get freed. A special
garbage collection task cleans this "scratch list" from time to time, or if
it overruns. The main profit is taken from the layers.library, which uses to
allocate tons of tiny snippets and is therefore the main cause for memory
fragmentation.

The "chip" memory is treated a bit different. It's also split into two 
distinct memory pools (small and large), but memory from the large pool
is allocated in reverse direction; this happens for two reasons: First, it
helps to keep the memory defragmentated, so the big pool can't run that
easely into the small pool. Second, it works around a hardware bug of my
computer (the refresh of the high end chip memory in my computer seems to
be a bit buggy - some bits tend to flip if they aren't frequently accessed,
for example by the DMA processor as display memory.)

For details about the PatchRAM program, check its readme file. As I said, if
you run PoolMem, you're supposed to run PatchRAM as well. It helps PoolMem
a lot in its job!

_________________________________________________________________________________

Additional programs:

The PoolMem program is still in a somewhat experimental stage, even though
it's running stable for my system for more than two years now - I won't
expect any serious bugs, though.
However, if you like to see how PoolMem works and if it has any effects, I
provided several extra programs:

ShowMem:		Shows the allocated/free memory in a graphical over-
			view. For details, check the ShowMem readme and its
			guide. (Available separately as well)

PatchRAM:		Modifies and improves the RAM disk. Shows the correct
			size of the RAM drive, improves the memory allocation
			sheme of it as well. Should be run together with
			PoolMem. For details, check the guide of PatchRAM.

FragMeter:		Calculates the fragmentation of your memory. The
			output is given separately for each memory type.
			A 100% defragmentation indicates that all the free
			memory is messed up in tiny blocks of eight bytes
			each (maximal defragmentation).
			A Shannon-type approach is used to measure the
			defragmentation (the algorithm calculates the
			Shannon entropy of the memory blocks with the formula
			sum += log(chunk->mc_Bytes/total)
			If you've a better approach for measuring the
			fragmentation, lemme now. This here seems at least
			reasonable for me as a theoretical physicst... ;-)
			
			This program can be used to test the efficency of
			PoolMem. My measurements indicate that the entropy is
			about halved.

MemoryMess:		A program that tries to fragmentate the main memory
			as worse as possible by allocating and freeing memory
			in random order. Can be used together with the 
			FragMeter to measure the efficiency of PoolMem or
			with ShowMem to watch PoolMem at its job. Can be
			canceled safely with ^C (Control-C).

If you've ideas how to improve PoolMem, lemme know....

______________________________________________________________________________

                        The THOR-Software Licence


This License applies to the computer programs known as "PoolMem", "ShowMem",
"FragMeter", "MemoryMess" and "ShowMem".
The "Program", below, refers to such program.


The programs and files in this distribution are freely distributable
under the restrictions stated below, but are also Copyright (c)
Thomas Richter.


Distribution of the Program by a commercial organization without written
permission from the author to any third party is prohibited if any payment
is made in connection with such distribution, whether directly
(as in payment for a copy of the Program) or indirectly (as in payment
for some service related to the Program, or payment for some product
or service that includes a copy of the Program "without charge";
these are only examples, and not an exhaustive enumeration of prohibited
activities). However, the following methods of distribution involving
payment shall not in and of themselves be a violation of this restriction:


(i) Posting the Program on a public access information storage and
retrieval service for which a fee is received for retrieving information
(such as an on-line service), provided that the fee is not
content-dependent (i.e., the fee would be the same for retrieving the same
volume of information consisting of random data).



(ii) Distributing the Program on a CD-ROM, provided that the files
containing the Program are reproduced entirely and verbatim on such
CD-ROM, and provided further that all information on such CD-ROM be
redistributable for non-commercial purposes without charge.



Everything in this distribution must be kept together, in original
and unmodified form.




Limitations.

THE PROGRAM IS PROVIDED TO YOU "AS IS," WITHOUT WARRANTY. THERE IS NO
WARRANTY FOR THE PROGRAM, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. THE ENTIRE
RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD
THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY
SERVICING, REPAIR OR CORRECTION.



IF YOU DO NOT ACCEPT THIS LICENCE, YOU MUST DELETE ALL FILES CONTAINED IN
THIS ARCHIVE.

______________________________________________________________________________

Have fun,
	Thomas		December 1997


============================= Archive contents =============================

Original  Packed Ratio    Date     Time    Name
-------- ------- ----- --------- --------  -------------
    4952    3466 30.0% 05-Dec-97 22:42:30 +FragMeter
    9432    4583 51.4% 29-Nov-97 20:22:46 +MemoryMess
    1140     788 30.8% 29-Nov-97 20:23:12 +PatchRAM
    2949    1454 50.6% 29-Nov-97 20:23:12 +PatchRAM.readme
     856     375 56.1% 29-Nov-97 20:43:26 +PatchRAM.readme.info
    4072    2679 34.2% 29-Nov-97 15:39:22 +PoolMem
    8305    3597 56.6% 05-Dec-97 22:48:58 +PoolMem.readme
     856     375 56.1% 29-Nov-97 20:43:24 +PoolMem.readme.info
    3256    2089 35.8% 29-Nov-97 20:23:40 +ShowMem
    4415    2095 52.5% 29-Nov-97 20:23:40 +ShowMem.guide
     537     286 46.7% 29-Nov-97 20:43:24 +ShowMem.guide.info
    1038     323 68.8% 29-Nov-97 20:43:24 +ShowMem.info
    9526    5060 46.8% 29-Nov-97 20:23:36 +ShowMem.pic
     540     312 42.2% 29-Nov-97 20:23:36 +ShowMem.readme
-------- ------- ----- --------- --------
   51874   27482 47.0% 08-Dec-97 19:21:54   14 files
